<?php
final class Controller_Account extends Controller_Security{
    public function Acquiescent(){
        Template::Assign('AlertContainerDisplaySwitch','none');
        Template::Assign('AlertContent','');
        Template::Display('account/password.html');
    }

    protected function Password(){
        $newPassword=$_POST['NewPassword'];
        $oldPassword=Model_Account::Hash($_POST['OldPassword']);
        $data=Database::GetRowByValue('tryphp_admin_account','Username','admin');
        if($oldPassword!==$data['Password']){
            Template::Assign('AlertContainerDisplaySwitch','block');
            Template::Assign('AlertContent','原密码不正确。');
        }
        else{
            Database::UpdateRowsByValue('tryphp_admin_account','Username','admin',array(
                'Password'=>Model_Account::Hash($_POST['NewPassword'])
            ));
            Model_Account::Login('admin',Model_Account::Hash($_POST['NewPassword']));
            Template::Assign('AlertContainerDisplaySwitch','block');
            Template::Assign('AlertContent','密码修改成功。');
        }
        #渲染模板
        Template::Display('account/password.html');
    }
}
?>